package cn.zwx.starter;

import cn.zwx.common.PropertyFactory;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;


/**
 * @author zhangwenxue
 */
@Data
@ConfigurationProperties(prefix = "distributed.id")
public class DistributedIdSpringBootProperties {

    private String name;
    private Segment segment;
    private Snowflake snowflake;

    public void setName(String name) {
        PropertyFactory.setLeafName(name);
        this.name = name;
    }

    @Data
    public static class Segment{
        private boolean enable=false;
        private String url;
        private String username;
        private String password;

    }
    @Data
    public static class Snowflake {
        private boolean enable = false;

        private String zkPath;

        @Value("server.port")
        private int port;

        /**
         * sessionTimeoutMs
         */
        private Integer sessionTimeoutMs;
        /**
         * connectionTimeoutMs
         */
        private Integer connectionTimeoutMs;
    }

}
